package com.ybkj.o2o.zhuanxian.mapper;

import com.ybkj.o2o.zhuanxian.common.CompanyOrderVo;
import com.ybkj.o2o.zhuanxian.common.DriverOrderDetailVo;
import com.ybkj.o2o.zhuanxian.common.DriverOrderVo;
import com.ybkj.o2o.zhuanxian.common.MemberOrderVo;
import com.ybkj.o2o.zhuanxian.entity.Order;

import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderMapper {
  void insertCycleRecord(Map<String,Object> map);

  List<Map<String,Object>> redPacketCycle(@Param("orderDate") Date orderDate, @Param("cycle") String cycle);

  List<Order> cycleOrder(@Param("startDate") Date startDate, @Param("endDate") Date endDate);

  int insert(Order record);

  Order findByIdAndAppKey(@Param("id") Long id, @Param("appkey") String appkey);

  int update(Order order);

  int updateIngoreNull(Order order);

  List<Order> findOrderByEmployId(@Param("employId") Long employId, @Param("money") Double money,
      @Param("appkey") String appkey, @Param("startTime") Long startTime,
      @Param("endTime") Long endTime);

  List<Order> findByParam(@Param("start") Date start, @Param("end") Date end,
      @Param("companyId") Long companyId, @Param("companyName") String companyName,
      @Param("orderNo") String orderNo, @Param("passengerId") Long passengerId,
      @Param("passengerName") String passengerName, @Param("passengerPhone") String passengerPhone,
      @Param("employId") Long employId, @Param("employName") String employName,
      @Param("employPhone") String employPhone, @Param("carNumber") String carNumber,
      @Param("orderby") String orderby, @Param("allorderType") List<String> allorderType,
      @Param("allstatus") List<Integer> allstatus, @Param("rows") Integer rows,
      @Param("offset") Integer offset, @Param("treatment") Boolean treatment,
      @Param("startFinish") Date startFinish, @Param("endFinish") Date endFinish,
      @Param("lineId") Long lineId, @Param("appkey") String appkey, @Param("linesId") List<Long> linesId);

  Long countByParam(@Param("start") Date start, @Param("end") Date end,
      @Param("companyId") Long companyId, @Param("companyName") String companyName,
      @Param("orderNo") String orderNo, @Param("passengerId") Long passengerId,
      @Param("passengerName") String passengerName, @Param("passengerPhone") String passengerPhone,
      @Param("employId") Long employId, @Param("employName") String employName,
      @Param("employPhone") String employPhone, @Param("carNumber") String carNumber,
      @Param("orderby") String orderby, @Param("allorderType") List<String> allorderType,
      @Param("allstatus") List<Integer> allstatus, @Param("treatment") Boolean treatment,
      @Param("startFinish") Date startFinish, @Param("endFinish") Date endFinish,
      @Param("lineId") Long lineId, @Param("appkey") String appkey, @Param("linesId") List<Long> linesId);

  Long countFinishByPassenger(@Param("passengerId") Long passengerId,
      @Param("startTime") Date startTime, @Param("endTime") Date endTime,
      @Param("appkey") String appkey, @Param("channelNames") List<String> channelNames);

  List<Order> findMyFinishOrder(@Param("passengerId") Long passengerId,
      @Param("appkey") String appkey);

  long countForToday(@Param("start") Date start, @Param("end") Date end,
      @Param("appkey") String appkey);

  long finishOrderCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
      @Param("companyId") Long companyId, @Param("appkey") String appkey);

  long destroyOrderCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
      @Param("companyId") Long companyId, @Param("appkey") String appkey);

  Order selectFinishedByDriverWithDate(@Param("employId") Long employId,
      @Param("start") Date start, @Param("end") Date end, @Param("offset") Integer offset,
      @Param("size") Integer size);

  List<Order> selectMonthOrder(@Param("start") Date start, @Param("end") Date end);

  List<MemberOrderVo> selectMemberOrder(@Param("startTime") Date startTime,
      @Param("endTime") Date endTime, @Param("companyId") Long companyId,
      @Param("appkey") String appkey);

  List<String> queryAllFromSource(@Param("companyId") Long companyId, 
      @Param("appkey") String appkey);

  Map<String, Object> findByFromSource(@Param("start") Date start, @Param("end") Date end,
      @Param("companyId") Long companyId, @Param("fromSource") String fromSource,
      @Param("appkey") String appkey);

  List<Map<String, Object>> findDetailByFromSource(@Param("start") Date start,
      @Param("end") Date end, @Param("companyId") Long companyId,
      @Param("fromSource") String fromSource, @Param("appkey") String appkey);

  List<DriverOrderVo> queryAllDriverAchievement(@Param("start") Date start, @Param("end") Date end,
      @Param("empCompanyId") Long empCompanyId, @Param("appkey") String appkey);

  List<String> queryAllCompany(@Param("appkey") String appkey);

  List<CompanyOrderVo> companyOrders(@Param("start") Date start, @Param("end") Date end,
      @Param("appkey") String appkey);

  List<CompanyOrderVo> companyCancelNums(@Param("start") Date start, @Param("end") Date end,
      @Param("appkey") String appkey);

  List<DriverOrderDetailVo> queryDetailByDriverId(@Param("driverId") Long driverId,
      @Param("start") Date start, @Param("end") Date end, @Param("offset") Integer offset,
      @Param("rows") Integer rows, @Param("appkey") String appkey);

  List<Order> queryFinishOrderByEmployId(@Param("employId") Long employId,
      @Param("sdate") Date sdate, @Param("edate") Date edate, @Param("appkey") String appkey,
      @Param("offset") Integer offset, @Param("rows") Integer rows);

  Long countFinishOrderByEmployId(@Param("employId") Long employId, @Param("sdate") Date sdate,
      @Param("edate") Date edate, @Param("appkey") String appkey);

  Long countByPassengerId(@Param("passengerId") Long passengerId,
      @Param("channelNameList") List<String> channelNameList, @Param("appkey") String appkey);

  Long countRunning(@Param("passengerId") Long passengerId, @Param("startDate") Date startDate,
      @Param("endDate") Date endDate, @Param("channelNameList") List<String> channelNameList,
      @Param("appkey") String appkey);

  List<Order> selectActivedByEmploy(@Param("employId") Long employId,
      @Param("appkey") String appkey);

  List<Order> selectNewOrder(@Param("companyId") Long companyId, @Param("appkey") String appkey);

  List<Order> findRunOrderByEmployId(@Param("employId") Long employId, @Param("treatment") Boolean treatment,
      @Param("appkey") String appkey);

  Long queryRunOrder(@Param("passengerId") Long passengerId, @Param("appkey") String appkey);

  List<Order> findHastenOrder(@Param("appKey") String appKey);

  List<Order> findUnexecutedByEmployId(@Param("employId") Long employId,
      @Param("appkey") String appKey);

  List<Order> findOrderByPassenger(@Param("passengerId") Long passengerId,
      @Param("offset") Integer offset, @Param("rows") Integer rows, @Param("appKey") String appKey);

  Long countOrderByPassengerId(@Param("passengerId") Long passengerId,
      @Param("appKey") String appKey);

  List<Order> findByWork(@Param("employId") Long employId,
      @Param("statusList") List<Integer> statusList, @Param("appKey") String appKey);

  List<Order> findRunOrderByLineId(@Param("lineId") Long lineId, @Param("appKey") String appKey);

  List<Order> findRunOrderByCarId(@Param("carId") Long carId, @Param("appKey") String appKey);

  List<Order> findJiedanOrderByEmployId(@Param("employId") Long employId,
      @Param("appKey") String appKey);

  Order selectPrepare(@Param("orderId")Long orderId, @Param("appKey") String appKey);

  int updateFinishTime(@Param("orderId") Long orderId, @Param("appKey") String appKey);

  Long driverOrderDetailCount(@Param("employId") Long employId, @Param("startDate") Date startDate,
                              @Param("endDate") Date endDate, @Param("appKey") String appKey);

  int updateAnonymousNumber(@Param("orderId") Long orderId, @Param("appKey") String appKey,
                            @Param("anonymousNumber") String anonymousNumber);
}
